<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>后盾人</title>
  </head>
  <body></body>
  <script>
    "use strict";
    const user = {
      data: { name: "后盾人", age: 10 },
      set age(value) {
        if (typeof value != "number" || value < 10 || value > 100) {
          throw new Error("年龄格式错误");
        }
        this.data.age = value;
      },
      get age() {
        return this.data.age + "岁";
      }
    };
    // user.setAge(999);
    user.age = 87;
    console.log(user.age);
    // user.age = 19999;
  </script>
</html>
